#include "mainwindow.h"
#include "./ui_mainwindow.h"
#include <QMovie>
#include <QDebug>
#include <QGuiApplication>
#include <QScreen>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QMovie *movie = new QMovie(":/loading.gif");
    movie->setScaledSize(QSize(80, 80));
    movie->start();
    ui->info_msg->setMovie(movie);
    _mainWidgetWight = ui->mainWidget->width();
    _mainWidgetHeight = ui->mainWidget->height();
    resetPosition();
}

void MainWindow::resetPosition() {
    QScreen *screen = QGuiApplication::primaryScreen ();
    QRect screenRect = screen->geometry();
    int width = (screenRect.width() - _mainWidgetWight) / 2;
    int height = (screenRect.height() - _mainWidgetHeight)/4;
    ui->mainWidget->setGeometry(width, height, _mainWidgetWight, _mainWidgetHeight);
    resize(screenRect.width(), screenRect.height());
    showFullScreen();
}

MainWindow::~MainWindow()
{
    delete ui;
}

